#!/bin/bash
echo "Checking JDK..."
if type -p javac; then
	echo "Found JDK in PATH"
	_javac=javac
elif [[ -n $JAVA_HOME ]] && [[ -x "$JAVA_HOME/bin/javac" ]]; then
	echo "Found JDK in JAVA_HOME"
	_javac="$JAVA_HOME/bin/javac"
else
	echo "No JDK found"
	echo "Installing Java JDK..."
	sudo apt-get update
	sudo apt-get install java -y
fi
if [[ "$_javac" ]]; then
	version=$("$_javac" -version 2>&1 | awk '{print $2}')
	echo Version "$version"
fi